import java.util.Arrays;
public class Dome {
    public static int[] random() {
        int[] array = new int[10];
        for(int i = 0;i<10;i++) {
            array[i] = (int)(Math.random()*100);
        }
        return array;
    }
    static int[] array = random();
    static int  old = 0;
    static int even = 0;
    public static void main(String[] args) throws InterruptedException {

        Thread t1 = new Thread(()->
        {

            for (int i = 0; i < array.length; i+=2) {
                old+=array[i];
            }
            System.out.println("奇数下表和为"+old);
            System.out.println(Arrays.toString(array));
        });
        Thread t2 = new Thread(()-> {

            for (int i = 1; i < array.length; i+=2) {
                even+=array[i];
            }
            System.out.println("偶数下标和为"+even);
            System.out.println("--------------------");
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println("数组和为"+(old+even));
    }
}
